<template>
  <div class="dashboard-container">
    <component :is="currentRole"></component>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import activePublisherDashboard from './activePublisher'
import examinationStaffDashboard from './examinationStaff'
import examineeDashboard from './examinee'

export default {
  name: 'dashboard',
  components: { adminDashboard, activePublisherDashboard, examinationStaffDashboard, examineeDashboard },
  data() {
    return {
      currentRole: 'adminDashboard'
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    if (this.roles.includes('admin')) {
      this.currentRole = 'adminDashboard'
    } else if (this.roles.includes('Publisher')) {
      this.currentRole = 'activePublisherDashboard'
    } else if (this.roles.includes('Staff')) {
      this.currentRole = 'examinationStaffDashboard'
    } else if (this.roles.includes('examinee')) {
      this.currentRole = 'examineeDashboard'
    } else {
      this.currentRole = ''
    }
  }
}
</script>
